package d7_thread_communicate;


//消费者线程
public class ConsumerThread extends Thread {

    private Desk desk;

    public ConsumerThread(String name, Desk desk) {
        super(name);
        this.desk = desk;
    }
    //重写run方法,指明线程要干的事情

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);//先让当前线程睡1秒,然后再继续执行
                //调用方法让桌子,吃包子
                desk.get();//
            } catch (Exception e) {
                e.printStackTrace();//打印堆栈的信息
            }
        }

    }
}
